package dsk.demo.product.controller.automarket;

import dsk.demo.common.utils.R;
import dsk.demo.product.entity.MailtempEntity;
import dsk.demo.product.service.MailtempService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("mailtemp")
public class MailtempController {
    @Autowired
    private MailtempService mailtempService;


    @GetMapping("/list")
    public R list() {
        List<MailtempEntity> list = mailtempService.list();
        return R.ok().put("data", list);
    }

    @PostMapping("/saveOrUpdate")
    public R save(@RequestBody MailtempEntity entity) {
        mailtempService.saveOrUpdate(entity);
        return R.ok();
    }

    @GetMapping("/delete/{id}")
    public R delete(@PathVariable("id") Long id) {
        mailtempService.removeById(id);
        return R.ok();
    }

    @GetMapping("/info/{id}")
    public R list(@PathVariable("id") Long id) {
        MailtempEntity entity = mailtempService.getById(id);
        return R.ok().put("data", entity);
    }

}
